/*!
 * LMV v6.4.1
 * 
 * Copyright 2019 Autodesk, Inc.
 * All rights reserved.
 * 
 * This computer source code and related instructions and comments are the
 * unpublished confidential and proprietary information of Autodesk, Inc.
 * and are protected under Federal copyright and state trade secret law.
 * They may not be disclosed to, copied or used by any third party without
 * the prior written consent of Autodesk, Inc.
 * 
 * Autodesk Forge Viewer Usage Limitations:
 * 
 * The Autodesk Forge viewer can only be used to view files generated by
 * Autodesk Forge services. The Autodesk Forge Viewer JavaScript must be
 * delivered from an Autodesk hosted URL.
 */
Autodesk.Extensions.Beeline =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./extensions/Beeline/Beeline.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./extensions/Beeline/Beeline.js":
/*!***************************************!*\
  !*** ./extensions/Beeline/Beeline.js ***!
  \***************************************/
/*! exports provided: BeelineExtension */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BeelineExtension", function() { return BeelineExtension; });
/* harmony import */ var _BeelineTool__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BeelineTool */ "./extensions/Beeline/BeelineTool.js");


'use strict';

function BeelineExtension(viewer, options) {
  Autodesk.Viewing.Extension.call(this, viewer, options);
  this.name = "beeline";
};

BeelineExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
BeelineExtension.prototype.constructor = BeelineExtension;

var proto = BeelineExtension.prototype;

proto.load = function () {
  var self = this;
  var viewer = this.viewer;
  var AVU = Autodesk.Viewing.UI;

  // Register tool
  this.tool = new _BeelineTool__WEBPACK_IMPORTED_MODULE_0__["BeelineTool"](viewer.impl, viewer);
  viewer.toolController.registerTool(this.tool);

  // Add UI
  // Add beeline button
  this.createUI();

  // Add hotkey
  var previousTool;
  function onPress() {
    previousTool = viewer.getActiveNavigationTool();
    viewer.setActiveNavigationTool(self.tool.getName());
    return true;
  }
  function onRelease() {
    viewer.setActiveNavigationTool(previousTool ? previousTool : viewer.defaultNavigationToolName);
    return true;
  }
  this.HOTKEYS_ID = "Autodesk.Beeline.Hotkeys";
  var hotkeys = [
  {
    keycodes: [
    Autodesk.Viewing.KeyCode.CONTROL,
    Autodesk.Viewing.KeyCode.ALT],

    onPress: onPress,
    onRelease: onRelease }];


  viewer.getHotkeyManager().pushHotkeys(this.HOTKEYS_ID, hotkeys);

  // Register listeners
  this.onToolChanged = function (e) {
    if (e.toolName.indexOf('beeline') === -1) {
      return;
    }

    if (self.beelineButton) {
      var state = e.active ? AVU.Button.State.ACTIVE : AVU.Button.State.INACTIVE;
      self.beelineButton.setState(state);
    }
  };

  viewer.addEventListener(Autodesk.Viewing.TOOL_CHANGE_EVENT, this.onToolChanged);

  return true;
};

proto.createUI = function ()
{
  var self = this;
  var viewer = this.viewer;
  if (!viewer.getToolbar || !viewer.getSettingsPanel) return; // Add support for Viewer3D instance

  var toolbar = viewer.getToolbar(true);

  var AVU = Autodesk.Viewing.UI;
  var navTools = toolbar.getControl(Autodesk.Viewing.TOOLBAR.NAVTOOLSID);

  var beelineButtonId = "toolbar-beelineTool";

  /*var options = {
                                                   defaultTooltipValue: "Walk to (double-click to Walk through)"
                                               };*/
  var beelineButton = new AVU.Button(beelineButtonId);
  beelineButton.setToolTip('Walk to');
  beelineButton.setIcon("adsk-icon-walk");
  beelineButton.onClick = function (e) {
    if (self.activeStatus) {
      self.deactivate();
    } else {
      self.activate();
    }
  };
  this.beelineButton = beelineButton;

  var cameraSubmenuTool = navTools.getControl('toolbar-cameraSubmenuTool');
  if (cameraSubmenuTool) {
    navTools.addControl(this.beelineButton, { index: navTools.indexOf(cameraSubmenuTool.getId()) });
  } else {
    navTools.addControl(this.beelineButton);
  }

  // Add beeline settings to the viewer's setting panel.
  var that = this;
  var addViewerUIOptions = function addViewerUIOptions() {
    viewer.removeEventListener(Autodesk.Viewing.TOOLBAR_CREATED_EVENT, addViewerUIOptions);

    var navTab = Autodesk.Viewing.Extensions.ViewerSettingTab.Navigation;
    var viewerOptions = viewer.getSettingsPanel(true);

    viewerOptions.addLabel(navTab, "Look Direction");

    that.viewerOption_LookHorId = viewerOptions.addCheckbox(navTab, "Reverse horizontal look direction", "Toggles direction of left and right camera movement", false, function (checked) {
      viewer.setReverseHorizontalLookDirection(checked);
    }, "reverseHorizontalLookDirection");

    that.viewerOption_LookVertId = viewerOptions.addCheckbox(navTab, "Reverse vertical look direction", "Toggles direction of up and down camera movement", false, function (checked) {
      viewer.setReverseVerticalLookDirection(checked);
    }, "reverseVerticalLookDirection");

  };

  if (this.viewer.getSettingsPanel(false)) {
    addViewerUIOptions();
  } else {
    this.viewer.addEventListener(Autodesk.Viewing.TOOLBAR_CREATED_EVENT, addViewerUIOptions);
  }
};

proto.unload = function () {
  var viewer = this.viewer;

  // Remove listeners
  viewer.removeEventListener(Autodesk.Viewing.TOOL_CHANGE_EVENT, this.onToolChanged);
  this.onToolChanged = undefined;

  // Remove hotkey
  viewer.getHotkeyManager().popHotkeys(this.HOTKEYS_ID);

  // Remove the UI
  if (this.beelineButton) {
    // Button is created only if toolbar API is available
    var toolbar = viewer.getToolbar(false);
    if (toolbar) {
      toolbar.getControl(Autodesk.Viewing.TOOLBAR.NAVTOOLSID).removeControl(this.beelineButton.getId());
    }
    this.beelineButton = null;
  }

  // Remove the options from the Viewer SettingsPanel.
  if (viewer.getSettingsPanel) {
    viewer.getSettingsPanel(false).removeCheckbox(this.viewerOption_LookHorId);
    viewer.getSettingsPanel(false).removeCheckbox(this.viewerOption_LookVertId);
  }

  //Uh, why does the viewer need to keep track of this in addition to the tool stack?
  if (viewer.getActiveNavigationTool() == this.tool.getName())
  viewer.setActiveNavigationTool();

  // Deregister tool
  viewer.toolController.deregisterTool(this.tool);
  this.tool = null;

  return true;
};

proto.activate = function () {
  if (!this.activeStatus) {
    this.viewer.setActiveNavigationTool(this.tool.getName());
    this.activeStatus = true;
  }
  return true;
};

proto.deactivate = function () {
  if (this.activeStatus) {
    this.viewer.setActiveNavigationTool();
    this.activeStatus = false;
  }
  return true;
};

Autodesk.Viewing.theExtensionManager.registerExtension('Autodesk.Beeline', BeelineExtension);

/***/ }),

/***/ "./extensions/Beeline/BeelineTool.js":
/*!*******************************************!*\
  !*** ./extensions/Beeline/BeelineTool.js ***!
  \*******************************************/
/*! exports provided: BeelineTool */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BeelineTool", function() { return BeelineTool; });

var avp = Autodesk.Viewing.Private;

// /** @constructor */
//
// TODO: Pass in the api instead of the impl, don't use the impl object.
//
function BeelineTool(viewerImpl, viewerApi)
{
  var MODE = {
    GO_TO: 0,
    PASS_THROUGH: 1,
    DEFAULT: 0 };


  // Constants
  var kDefaultFlightDuration = 1000; // milliseconds
  var kLookSensitivity = 0.8;
  var kMaxFocalLength = 28;
  var kDampingFactor = 0.7;

  // States
  var kStartState = 0;
  var kFlightState = 1;

  var self = this;
  var _viewerapi = viewerApi;
  var _container = viewerApi.container;
  var _autocam = viewerApi.autocam;
  var _navapi = viewerApi.navigation;
  var _viewerUtilities = viewerApi.utilities;
  var _names = ["beeline"];

  var _state = kStartState;
  var _isDragging = false;
  var _mouseButtons = 0;
  var _flightStartTime = null;
  var _flightDuration = null;
  var _intersectPointNear = new THREE.Vector3();
  var _intersectPointFar = new THREE.Vector3();
  var _flightStartPosition = new THREE.Vector3();
  var _flightEndPosition = new THREE.Vector3();
  var _haltAnimation = false;
  var _mouseXY = new THREE.Vector3();
  var _previousXY = new THREE.Vector3();

  var _expectedCameraState = null;
  var _touchType = null;

  function screenModeChanged()
  {
    self.revertToStartState();
  }

  // Utility methods
  function getCameraState(camera) {
    var state = {};

    state.target = camera.target.clone();
    state.worldup = camera.worldup.clone();

    state.position = camera.position.clone();
    state.up = camera.up.clone();

    var props = ['isPerspective', 'fov', 'zoom', 'aspect', 'left', 'right', 'top', 'bottom'];
    for (var i = 0; i < props.length; i++) {
      state[props[i]] = camera[props[i]];
    }

    return state;
  }

  function compareCameraToState(camera, state) {
    var result = camera.target.equals(state.target) &&
    camera.position.equals(state.position) &&
    camera.worldup.equals(state.worldup) &&
    camera.up.equals(state.up);

    if (!result) {
      return false;
    }

    var props = ['isPerspective', 'fov', 'zoom', 'aspect', 'left', 'right', 'top', 'bottom'];
    for (var i = 0; i < props.length; i++) {
      if (camera[props[i]] !== state[props[i]]) {
        return false;
      }
    }

    return true;
  }

  function getIntersectionPoints(normalizedScreenPosition) {
    var viewportVec = new THREE.Vector3(normalizedScreenPosition.x, normalizedScreenPosition.y, 1.0);
    var result = viewerImpl.hitTestViewport(viewportVec.clone(), false);

    if (!result || !result.intersectPoint) {
      return [];
    }

    var caster = new THREE.Raycaster();
    var vector = viewportVec.clone();
    var camera = viewerImpl.camera;
    var end = new THREE.Vector3(vector.x, vector.y, 1.0);

    vector.z = -1.0;
    vector = vector.unproject(camera);
    end = end.unproject(camera);
    end.sub(vector).normalize();
    caster.set(_navapi.isPerspective ? camera.position : vector, end);

    var intersects = [];

    // Get intersection points
    var frags = result.fragId instanceof Array ? result.fragId : [result.fragId];
    for (var i = 0; i < frags.length; i++) {
      var mesh = viewerImpl.getRenderProxy(viewerApi.model, frags[i]);

      avp.VBIntersector.meshRayCast(mesh, caster, intersects);
    }

    intersects.sort(function (a, b) {return a.distance - b.distance;});

    return intersects;
  }

  function prepareCamera() {
    if (!_navapi.isPerspective) {
      _navapi.toPerspective();
      _viewerUtilities.activatePivot(false);
    }
    if (_navapi.getFocalLength() > kMaxFocalLength) {
      _navapi.setFocalLength(kMaxFocalLength, true);
    }
  }

  // Tool methdos
  this.getNames = function ()
  {
    return _names;
  };

  this.getName = function ()
  {
    return _names[0];
  };

  this.activate = function (toolName)
  {
    _mouseButtons = 0;
    viewerApi.addEventListener(Autodesk.Viewing.FULLSCREEN_MODE_EVENT, screenModeChanged);
    _autocam.userLookSpeed = kLookSensitivity;
    this.showHUDMessage(true);
  };

  this.deactivate = function ()
  {
    viewerApi.removeEventListener(Autodesk.Viewing.FULLSCREEN_MODE_EVENT, screenModeChanged);
    this.revertToStartState();
    this.showHUDMessage(false);
  };

  this.getCursor = function ()
  {
    if (_isDragging) {
      return "url(), auto";
    } else if (_mouseButtons <= 1) {
      return "url(), auto";
    }

    return null;
  };

  this.update = function () {
    var camera = _navapi.getCamera();
    _isDragging = false;

    var moved = false;
    if (_mouseButtons === 1) {
      var deltaXY = _mouseXY.clone().sub(_previousXY);
      if (deltaXY.x !== 0 || deltaXY.y !== 0) {
        _isDragging = true;
        _previousXY.x += deltaXY.x * kDampingFactor;
        _previousXY.y += deltaXY.y * kDampingFactor;

        var worldDotCamera = _navapi.getWorldUpVector().dot(_navapi.getCameraUpVector());
        var horDirection = viewerApi.prefs.reverseHorizontalLookDirection ? -1 : 1;
        var vertDirection = viewerApi.prefs.reverseVerticalLookDirection ? -1 : 1;

        deltaXY.x *= worldDotCamera < 0 ? -horDirection : horDirection;
        deltaXY.y *= vertDirection;

        // Make sure we're synced with the camera
        _autocam.sync(_navapi.getCamera());
        _autocam.look(deltaXY);
        moved = true;

        _expectedCameraState = getCameraState(camera);
      }
    }
    return moved;
  };

  // Beeline methods
  this.revertToStartState = function ()
  {
    _viewerUtilities.pivotActive(false);
    _state = kStartState;
    _haltAnimation = true;
  };

  this.attemptFlight = function (normalizedScreenPosition, mode)
  {
    if (!_navapi.isActionEnabled('walk')) {
      return;
    }

    var intersectionPoints = getIntersectionPoints(normalizedScreenPosition);

    if (intersectionPoints.length > 0) {
      _intersectPointNear = intersectionPoints[0].point;
      _intersectPointFar = intersectionPoints[intersectionPoints.length - 1].point;
      self.fly(kDefaultFlightDuration, mode);
    }
  };

  this.fly = function (duration, mode)
  {
    // Pivot needs to be set before altering focal length to make it less jarring for the user. Changing the focal
    // length alters the camera's position and we need the camera's position to calculate the far pivot. Instead,
    // use approximation of where the far pivot will be (i.e. _intersectPointFar).
    _viewerUtilities.setPivotPoint(mode === MODE.GO_TO ? _intersectPointNear : _intersectPointFar, true, true);
    prepareCamera();

    _flightStartPosition = _navapi.getPosition();
    _flightDuration = duration;
    switch (mode) {
      case MODE.GO_TO:
        // Fly 80% of the way there
        _flightEndPosition = _flightStartPosition.clone().lerp(_intersectPointNear, 0.8);
        break;

      case MODE.PASS_THROUGH:
        // Fly 2 near planes past the object.
        var near = _autocam.camera.near * 2;
        var distance = _intersectPointFar.clone().sub(_flightStartPosition).length();
        var nearRatio = near / distance;

        _viewerUtilities.setPivotPoint(_flightStartPosition.clone().lerp(_intersectPointFar, 1 + 10 * nearRatio), true, true);
        _flightEndPosition = _flightStartPosition.clone().lerp(_intersectPointFar, 1 + nearRatio);
        break;

      default:
        return;}


    _state = kFlightState;

    _haltAnimation = false;
    _flightStartTime = null;

    requestAnimationFrame(self.step);
  };

  // Animating the camera
  this.step = function (timestamp)
  {
    var camera = _navapi.getCamera();

    if (_haltAnimation) {
      return;
    }

    if (_flightStartTime === null) {
      _expectedCameraState = getCameraState(camera);

      _flightStartTime = timestamp;
    } else if (!compareCameraToState(camera, _expectedCameraState)) {
      self.revertToStartState();
      return;
    }

    var flightTime = timestamp - _flightStartTime;
    var t = flightTime < _flightDuration ? flightTime / _flightDuration : 1;

    var newPosition = _flightStartPosition.clone().lerp(_flightEndPosition, t);

    // Keep target the same distance as the pivot
    var viewVec = _navapi.getEyeVector();
    viewVec.multiplyScalar(_navapi.getPivotPoint().sub(_navapi.getPosition()).length() / viewVec.length());

    _navapi.setView(newPosition, viewVec.add(newPosition));

    _expectedCameraState = getCameraState(camera);

    _viewerUtilities.activatePivot(false);

    if (flightTime < _flightDuration) {
      requestAnimationFrame(self.step);
    } else {
      self.revertToStartState();
    }
  };

  // ------------------------
  // Event handler callbacks:
  // These can use "this".

  this.handleGesture = function (event)
  {
    Autodesk.Viewing.Private.HudMessage.dismiss();

    switch (event.type) {

      case "dragstart":
        _touchType = "drag";
        // Single touch, fake the mouse for now...
        return this.handleButtonDown(event, 0);

      case "dragmove":
        return _touchType === "drag" ? this.handleMouseMove(event) : false;

      case "dragend":
        if (_touchType === "drag")
        {
          this.handleButtonUp(event, 0);
          _touchType = null;
          return true;
        }
        return false;}

    return false;
  };


  this.handleButtonDown = function (event, button)
  {
    Autodesk.Viewing.Private.HudMessage.dismiss();

    _mouseButtons += 1 << button;

    if (button === 0) {
      _previousXY.x = _mouseXY.x = event.canvasX;
      _previousXY.y = _mouseXY.y = event.canvasY;
      return true;
    }
    return false;
  };

  this.handleButtonUp = function (event, button)
  {
    _mouseButtons -= 1 << button;

    if (button === 0) {
      return true;
    }
    return false;
  };

  this.handleSingleClick = function (event, button)
  {
    Autodesk.Viewing.Private.HudMessage.dismiss();

    // Anything besides LMB should revert viewer to initial state
    if (button === 0) {
      var normalizedScreenLocation = {
        x: event.normalizedX,
        y: event.normalizedY };


      switch (_state) {
        case kStartState:
          self.attemptFlight(normalizedScreenLocation, MODE.GO_TO);
          break;

        case kFlightState:
          self.revertToStartState();
          break;

        default:
          break;}

    } else {
      this.revertToStartState();
      return false;
    }

    return true;
  };

  this.handleSingleTap = function (event)
  {
    return this.handleSingleClick(event, 0);
  };

  this.handleDoubleTap = function (event)
  {
    if (event.pointers && event.pointers.length === 1) {
      self.attemptFlight({ x: event.normalizedX, y: event.normalizedY }, MODE.PASS_THROUGH);
      return true;
    }
    return false;
  };

  this.handleDoubleClick = function (event, button)
  {
    if (button === 0) {
      self.attemptFlight({ x: event.normalizedX, y: event.normalizedY }, MODE.PASS_THROUGH);
      return true;
    }

    return false;
  };

  this.handleMouseMove = function (event)
  {
    _mouseXY.x = event.canvasX;
    _mouseXY.y = event.canvasY;

    if (_mouseButtons === 1) {
      prepareCamera();
      return true;
    }

    return false;
  };

  this.handleBlur = function (event)
  {
    // Reset things when we lose focus...
    this.revertToStartState();
    return false;
  };

  this.showOrthoWarningMessage = function ()
  {
    var messageSpecs = {
      "msgTitleKey": "Orthographic View Set",
      "messageKey": "The view is set to Orthographic Beeline",
      "messageDefaultValue": "The view is set to Orthographic. Using this tool will switch to Perspective." };

    var closeCallback = function closeCallback() {}; // dummy callback function so that the 'X' is shown
    Autodesk.Viewing.Private.HudMessage.displayMessage(_container, messageSpecs, closeCallback);
  };

  this.showFocalWarningMessage = function ()
  {
    var messageSpecs = {
      "msgTitleKey": "Long Focal Length View Set",
      "messageKey": "The view is set to a long focal length",
      "messageDefaultValue": "This view has a long focal length. Using this tool will set a short focal length." };

    var closeCallback = function closeCallback() {}; // dummy callback function so that the 'X' is shown
    Autodesk.Viewing.Private.HudMessage.displayMessage(_container, messageSpecs, closeCallback);
  };

  this.watchCamera = function (e)
  {
    // If camera changed to ORTHO and we are still in Beeline mode
    // put up the warning message that the system will switch to perspective.
    // Similarly, warn for long focal length.
    if (_viewerapi.toolController.getActiveToolName() === _names[0] ||
    _viewerapi.toolController.getActiveToolName() === _names[1]) {
      var camera = _navapi.getCamera();
      var isOrtho = camera && !camera.isPerspective;
      var hasLongFocalLength = _navapi.getFocalLength() > kMaxFocalLength;

      if (isOrtho)
      self.showOrthoWarningMessage();else
      if (hasLongFocalLength)
      self.showFocalWarningMessage();else

      Autodesk.Viewing.Private.HudMessage.dismiss();
    }
  };

  this.showHUDMessage = function (state)
  {
    var camera = _navapi.getCamera();
    var isOrtho = camera && !camera.isPerspective;
    var hasLongFocalLength = _navapi.getFocalLength() > kMaxFocalLength;

    if (state && isOrtho) {
      self.showOrthoWarningMessage();
    } else if (state && hasLongFocalLength) {
      self.showFocalWarningMessage();
    } else {
      Autodesk.Viewing.Private.HudMessage.dismiss();
    }

    if (state) {
      _viewerapi.addEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT, self.watchCamera);
    } else {
      _viewerapi.removeEventListener(Autodesk.Viewing.CAMERA_CHANGE_EVENT, self.watchCamera);
    }
  };

};

/***/ })

/******/ });